using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX.DirectDraw;
using Microsoft.DirectX.DirectInput;
using TowerDefense_Dx.Core;

namespace TowerDefense_Dx.Button
{
    public class NextScreen:DxButton
    {
        public NextScreen(string imagePath, Microsoft.DirectX.DirectDraw.Device graphicDevice, int frameWidth, int frameHeight, PointF position)            :
            base(imagePath, graphicDevice, frameWidth, frameHeight, position)
        {

        }
        public override void Update(MouseState state)
        {
            _buttons = state.GetMouseButtons();
            {
                if (_buttons[0] != 0)
                {
                    if (_bounding.Contains(Cursor.Position))
                    {
                        if (_state == BUTTON_STATE.NORMAL)
                        {
                            _state = BUTTON_STATE.HOLD;                           
                            if (_onMouseDown != null)
                            {
                                _onMouseDown();
                            }
                        }
                        else
                        {
                            if (_state == BUTTON_STATE.HOLD)
                            {
                                if (_onMouseDrag != null)
                                {
                                    _onMouseDrag();
                                }
                            }
                        }
                    }
                }
                else
                {
                    if (_state == BUTTON_STATE.HOLD)
                    {
                        _state = BUTTON_STATE.NORMAL;                       
                        if (_onMouseUp != null)
                        {
                            _onMouseUp();
                        }
                    }
                }
            }            
        }
        
    }
}
